﻿using JetBrains.Annotations;

namespace Bundler
{
    using System;
    using System.Collections.Generic;

    public class Bundle
    {
        #region Constants and Fields

        private readonly List<BundleItem> items;

        #endregion

        #region Constructors and Destructors

        public Bundle([NotNull] string virtualPath, [NotNull] Type bundleType, BundleOptions options = null)
        {
            VirtualPath = virtualPath;
            BundleType = bundleType;
            items = new List<BundleItem>();
            Options = options ?? new BundleOptions();
        }

        #endregion

        #region Public Properties

        public Type BundleType { get; private set; }
        public BundleOptions Options { get; private set; }

        public IEnumerable<BundleItem> Items
        {
            get { return items; }
        }

        public string VirtualPath { get; private set; }

        #endregion

        #region Public Methods and Operators

        public void AddFile([PathReference, NotNull] string virtualPath)
        {
            items.Add(new BundleItem
            {
                Value = virtualPath,
                Type = BundleContentSourceType.VirtualPath
            });
        }

        public void AddContent(string rawContent)
        {
            items.Add(new BundleItem
            {
                Value = rawContent,
                Type = BundleContentSourceType.RawContent
            });
        }

        #endregion
    }
}